﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Practices.Unity;
using SISLOG.BusinessEntities;
using SISLOG.BusinessLogic;

namespace SISLOG.Web
{
    public partial class frmMaterial : BasePage<frmMaterial>//System.Web.UI.Page
    {
        [Dependency]
        public IMaterialBL MaterialBL { get; set; }

        [Dependency]
        public IProveedorBL ProveedorBL { get; set; }
        
        protected void Page_Load(object sender, EventArgs e)
        {
            GridView1.DataSource = MaterialBL.GetAllFromMaterial();//para cargar los datos en la grilla
            GridView1.DataBind();//mostrar los datos de la grilla
        }

        protected void botonBuscar_Click(object sender, EventArgs e)
        {
            List<Material> listaMaterial = new List<Material>();

            if (RadioButton1.Checked)
            {
                listaMaterial = MaterialBL.GetAllFromMaterialByCriterio(txtCriterio.Text);
            }
            else
            {
                listaMaterial = MaterialBL.GetAllFromMaterialByProveedor(txtCriterio.Text);
            }

            GridView1.DataSource = listaMaterial;//para cargar los datos en la grilla
            GridView1.DataBind();//mostrar los datos de la grilla
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect("frmCRUDMaterial.aspx?acc=nuevo");
        }
    }
}